<template>

  <div>
       <NavBar title="主页"/>
<div class="all">
  <div class='all_header'></div> 
  <div class="all_content">
     <div class="head_blue">数据采集</div>
 <div class="BigBox" >
       <div class="item">
          <div class="box" @click="routerPush('my')">
            <img  src="../../assets/huabanfuben.png" class="itemImg" />
            <div class="itemTitle">个人业绩采集</div>
          </div>
        </div>
    </div>

  </div>

  <div class="all_content">
     <div class="head_blue">绩效查看</div>
  <div class="BigBox">
        <div class="item">
          <div class="box" @click="routerPush('high')">
            <img src="../../assets/shenhezhuangtai.png" class="itemImg" />
            <div class="itemTitle">正高绩效</div>
          </div>
        </div>
        <div class="item">
          <div class="box" @click="routerPush('leading')">
            <img src="../../assets/test.png" class="itemImg" />
            <div class="itemTitle">正处绩效</div>
          </div>
        </div>
        <div class="item">
          <div class="box" @click="routerPush('secretary')">
            <img src="../../assets/checklist.png" class="itemImg" />
            <div class="itemTitle">书记绩效</div>
          </div>
        </div>
     </div>  
      </div>


 <div class="all_content" >
     <div class="head_blue">考核评分</div>
 <div class="BigBox" >
        <div class="item">
          <div class="box" @click="routerPush('中层干部打分')">
            <img src="../../assets/page.png" class="itemImg" />
            <div class="itemTitle">中层干部打分</div>
          </div>
        </div>
        <div class="item">
          <div class="box" @click="routerPush('党支书评价')">
            <img src="../../assets/page.png" class="itemImg" />
            <div class="itemTitle">党支书评价</div>
          </div>
        </div>
          <div class="item">
          <div class="box" @click="routerPush('正高评价')">
            <img src="../../assets/page.png" class="itemImg" />
            <div class="itemTitle">正高评价</div>
          </div>
        </div>
      </div>
      </div>
  <div class="all_content">
     <div class="head_blue">考核排名</div>
     
       <div class="BigBox" >
        <div class="item">
          <div class="box" @click="routerPush('正处排名')">
            <img src="../../assets/visitor.png" class="itemImg" />
            <div class="itemTitle">正处排名</div>
          </div>
        </div>
        <div class="item">
          <div class="box" @click="routerPush('院长排名')">
            <img src="../../assets/seo.png" class="itemImg" />
            <div class="itemTitle">院长排名</div>
          </div>
        </div>
         <div class="item">
          <div class="box" @click="routerPush('书记排名')">
            <img src="../../assets/responsive.png" class="itemImg" />
            <div class="itemTitle">书记排名</div>
          </div>
        </div>
          <div class="item">
          <div class="box" @click="routerPush('中层副职排名')">
            <img src="../../assets/newsletter.png" class="itemImg" />
            <div class="itemTitle">中层副职排名</div>
          </div>
        </div>
         <div class="item">
          <div class="box" @click="routerPush('党支部书记排名')">
            <img src="../../assets/newsletter.png" class="itemImg" />
            <div class="itemTitle">党支部书记排名</div>
          </div>
        </div>
          <div class="item">
          <div class="box" @click="routerPush('学院绩效排名')">
            <img src="../../assets/newsletter.png" class="itemImg" />
            <div class="itemTitle">学院绩效排名</div>
          </div>
        </div>
          <div class="item">
          <div class="box" @click="routerPush('部门绩效排名')">
            <img src="../../assets/newsletter.png" class="itemImg" />
            <div class="itemTitle">部门绩效排名</div>
          </div>
        </div>
      </div>
</div>
</div>
   
   
  
  </div>
</template>

<script>
import request from "../../utils/request"
import NavBar from "../../components/NavBar/navBar";
import { Dialog } from 'vant';

export default {
 components: {
    NavBar
  },
  name: 'Home',
  async created () {
    //
    let res = await request({
      url:"/voter",method:"get",
      params:{query:{number:this.$root.user.number}}
    })
    if(res.data.length>0)
    {
      this.canVote=true;
    }
      res = await request({
      url:"/shujiVoter",method:"get",
      params:{query:{number:this.$root.user.number}}
    })
    
    if(res.data.length>0)
    {
      this.canshujiVote=true;
    }
    

    //
  },
  data () {
    return {
      sort: 0,
      canVote:false,
      canshujiVote:false,
      users: null,
     
    }
  },
  methods: {
    routerPush (item) {
      switch (item) {
        case '部门绩效排名':
           if(this.$root.user.role.indexOf('党委组织部') !==-1 ||
            this.$root.user.role.indexOf('人事处') !==-1  || this.$root.user.role.indexOf('校领导') !==-1 )
           
             this.$router.push({name:'部门绩效排名'})
            else{
                Dialog.alert({message:'你没有权限查看'});
            }
          break;
        case '学院绩效排名':
          if(this.$root.user.role.indexOf('党委组织部') !==-1 ||
            this.$root.user.role.indexOf('人事处') !==-1  || this.$root.user.role.indexOf('校领导') !==-1 )
             this.$router.push({name:'学院绩效排名'})
            else{
                Dialog.alert({message:'你没有权限查看'});
            }
          break;
        case '中层副职排名':
          if(this.$root.user.role.indexOf('党委组织部') !==-1 
         
          || this.$root.user.role.indexOf('校领导') !==-1 )
           
             this.$router.push('/zhongcunfuzhipaiming')
            else{
                Dialog.alert({message:'你没有权限查看'});
            }
          break;
           case '院长排名':
             if(this.$root.user.role.indexOf('党委组织部') !==-1  || this.$root.user.role.indexOf('校领导') !==-1 )
             this.$router.push('/yuanzhangpaiming')
            else{
                
                  Dialog.alert({message:'你没有权限查看'});
            }
          break;
           case '正处排名':
             if(this.$root.user.role.indexOf('党委组织部') !==-1  || this.$root.user.role.indexOf('校领导') !==-1 )
              this.$router.push('/chuzhangpaiming')
            else{
                Dialog.alert({message:'你没有权限查看'});
              
            }
          break;
          
           case '书记排名':
             if(this.$root.user.role.indexOf('党委组织部') !==-1  || this.$root.user.role.indexOf('校领导') !==-1 )
            this.$router.push('/shujipaiming')
            else{
               Dialog.alert({message:'你没有权限查看'});
                 
            }
          break;
          case '党支部书记排名':
            if(this.$root.user.role.indexOf('党委组织部') !==-1  || this.$root.user.role.indexOf('校领导') !==-1 )
             this.$router.push({name:'党支部书记排名'})
            else{
               Dialog.alert({message:'你没有权限查看'});
          
            }
            break;
        case 'my':
          this.$router.push('/my')
          break
        case 'department':
          this.$router.push('/department')
          break
        case 'cadre':
          this.$router.push('/cadre')
          break
        case 'high':
          this.$router.push('/high')
          break
        case 'leading':
          this.$router.push('/leading')
          break
        case 'secretary':
          this.$router.push('/secretary')
          break
        case 'heighScore':
          this.$router.push('/heighScore')
          break
        case 'shuJi':
          this.$router.push('/shuJi')
          break
        case '党支书评价':
          if( this.canshujiVote)
            this.$router.push({name:'党支书评价'})
          else{
            Dialog.alert({message:'你没有此项打分资格'});
          }
          break;
        case '中层干部打分':
            if(this.canVote )
         
            this.$router.push('/zhongchen')
          else{
            Dialog.alert({message:'你没有此项打分资格'});
          }
          break;
        case '正高评价':
          if(this.canVote )
         
            this.$router.push({name:'正高评价'})
          else{
            Dialog.alert({message:'你没有此项打分资格'});
          break;
          }

      }
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.icon {
  width: 100%;
}
.swipe {
  position: absolute;
}
.itemText {
  padding-left: 0.5rem;
  font-size: 0.9rem;
  color: rgb(43, 39, 39);
}
.itemSel {
  margin-top: 0.5rem;
  width: 100%;
  display: flex;
  justify-content: center;
}
.item {
  width: 33vw;
  height: 8rem;
  
}
.box {
  width: 93%;
  height: 93%;
  margin: auto;
  text-align: center;
}
.itemImg {
  margin-top: 0.99rem;
  width: 60px;
}
.BigBox {
  background-color: white;
  border-radius: 5px;
  height: 65%;
  display: flex;
  flex-direction: row;
  flex-wrap:wrap;
 
  
}
.hr {
  width: 80%;
}
.laBa {
  width: 12px;
  margin-right: 2px;
}
.itemTitle {
  font-size: 0.6rem;
  margin-top: 0.6rem;
}
.all{
  display:flex;
  flex-direction: column;

}
.all_header{
  height: 0px;
  background-color: aliceblue;
}
.all_content{
  display: flex;
  flex-direction: column;
}
.head_blue{
  width: 100%;
  background-color: #1474e4;
  height: 45px;
  line-height: 45px;
  padding-left: 10px;
  color: #fff;
}
</style>
